//
//  HttpController.swift
//  DBFM
//
//  Created by iMac on 15/12/12.
//  Copyright © 2015年 kuai. All rights reserved.
//

import UIKit
import Alamofire

class HTTPController: NSObject {
    //定义一个代理
    var delegate:HttpProtocol?
    
    //
    func onsearch(url:String) {
        Alamofire.request(.GET, url)
            .responseJSON { response in
                //print(response.request)  // original URL request
                //print(response.response) // URL response
                //print(response.data)     // server data
                //print(response.result)   // result of response serializations
                if let JSON = response.result.value {
                    //print("JSON: \(JSON)")
                }
                print("test111")
                if response.result.value == nil {
                    self.delegate?.didRecieveResults("error")
                }else {
                    self.delegate?.didRecieveResults(response.result.value!)
                }
                
        }
        
    }
}

protocol HttpProtocol {
    func didRecieveResults(results:AnyObject)
}